#!/bin/bash

binDir=wzgames/bin

function start() {
  # shellcheck disable=SC2009
  # shellcheck disable=SC2006
  p=`ps -ef | grep "$binDir"/"$1" |grep -v 'grep'|awk '{print $2}'`
  if [ "$p" ]
  then
      echo "$binDir/$1 is in running"
  else
    nohup ./bin/"$1" "$1" --config ./configs/boot.yaml --node dev-"$1"-1 > ./logs/"$1"_nohup.log 2>&1 &
  fi
}

function usage() {
  echo "Usage: $0 {api|uc|cat|g8|aviator|avtower|betower|roubig|routower|admin}"
  exit 1
}

if [ $# -eq 0 ]; then
  usage
fi

case "$1" in
    api|uc|cat|g8|aviator|avtower|betower|roubig|routower|admin)
        start "$1"
        ;;
    *)
    usage
esac